#ifndef __DS_BULLET_UTILS__
#define __DS_BULLET_UTILS__

#include <btBulletCollisionCommon.h>

namespace zen {
namespace utils {

class BulletConvert {
public:
	inline static btVector3 toBtVector3(const glm::vec3 &vector) {
		return btVector3(vector.x, vector.y, vector.z);
	}

    inline static btTransform toBtTransform(const glm::mat4x4 &matrix) {
        btTransform out;
        //out.setBasis(btMatrix3x3(matrix[0][0], matrix[1][0], matrix[2][0], matrix[0][1], matrix[1][1], matrix[2][1], matrix[0][2], matrix[1][2], matrix[2][2]));
        //out.setOrigin(btVector3(matrix[3][0], matrix[3][1], matrix[3][2]));
        out.setFromOpenGLMatrix(glm::value_ptr(matrix));
        return out;
    }

    inline static glm::mat4 fromBtTransform(const btTransform &transform) {
    	glm::mat4 out;
        /*out[0][3] = 0.0;
        out[1][3] = 0.0;
        out[2][3] = 0.0;
        out[3][3] = 1.0;
        btVector3 tmp = transform.getOrigin();
        out[3][0] = tmp.x();
        out[3][1] = tmp.y();
        out[3][2] = tmp.z();
        tmp = transform.getBasis().getRow(0);
        out[0][0] = tmp.x();
        out[1][0] = tmp.y();
        out[2][0] = tmp.z();
        tmp = transform.getBasis().getRow(1);
        out[0][1] = tmp.x();
        out[1][1] = tmp.y();
        out[2][1] = tmp.z();
        tmp = transform.getBasis().getRow(2);
        out[0][2] = tmp.x();
        out[1][2] = tmp.y();
        out[2][2] = tmp.z();*/
    	transform.getOpenGLMatrix(glm::value_ptr(out));
        return out;
    }
};

} // namespace utils
} // namespace zen

#endif
